package com.yixun.lbx.service.impl;

import com.yixun.lbx.entity.YxProBeeHive;
import com.yixun.lbx.mapper.farm.BeeHiveMapper;
import com.yixun.lbx.service.BeeHiveServie;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Service
@Transactional
public class BeeHiveServieImpl implements BeeHiveServie {
    private final BeeHiveMapper beeHiveMapper;
    public BeeHiveServieImpl(BeeHiveMapper beeHiveMapper) {
        this.beeHiveMapper = beeHiveMapper;
    }
    /**
     * @param map todo
     * @return java.lang.Integer
     * @apiNote getCount
     */
    @Override
    public Integer getCount(HashMap<String, Object> map) {
        return beeHiveMapper.getCount(map);
    }
    /**
     * @param map todo
     * @return java.util.List<com.yixun.lbx.entity.YxProBeeHive>
     * @apiNote getListByPage
     */
    @Override
    public List<YxProBeeHive> getListByPage(HashMap<String, Object> map) {
        return beeHiveMapper.getListByPage(map);
    }
    /**
     * @param map todo
     * @return int
     * @apiNote addBeeHive
     */
    @Override
    public int addBeeHive(HashMap<String, Object> map) {
        map.put("addTime", getDate());
        return beeHiveMapper.insert(map);
    }
    /**
     * @param map todo
     * @return int
     * @apiNote updateBeeHive
     */
    @Override
    public int updateBeeHive(HashMap<String, Object> map) {
        map.put("updateTime", getDate());
        return beeHiveMapper.updateByPrimaryKeySelective(map);
    }
    /**
     * @param map todo
     * @return int
     * @apiNote deleteBeeHive
     */
    @Override
    public int deleteBeeHive(HashMap<String, Object> map) {
        map.put("updateTime", getDate());
        map.put("isDelete", -1);
        return beeHiveMapper.updateByPrimaryKeySelective(map);
    }
    /**
     * @param beeHive todo
     * @return java.util.List<com.yixun.lbx.entity.YxProBeeHive>
     * @apiNote getCompanyProductByArgs
     */
    @Override
    public List<YxProBeeHive> getCompanyProductByArgs(YxProBeeHive beeHive) {
        return beeHiveMapper.getCompanyProductByArgs(beeHive);
    }
    /**
     * @param map todo
     * @return java.util.List<com.yixun.lbx.entity.YxProBeeHive>
     * @apiNote getSearchListByPage
     */
    @Override
    public List<YxProBeeHive> getSearchListByPage(HashMap<String, String> map) {
        return beeHiveMapper.getSearchListByPage(map);

    }
    /**
     * @return java.lang.String
     * @apiNote getDate
     */
    private String getDate() {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(new Date());
    }
}
